define(["jquery", "easy-admin"], function ($, ea) {
    var init = {
      table_elem: "#currentTable",
      table_render_id: "currentTableRenderId",
      index_url: "crm/clues.index/index",
      add_url: "crm/clues.index/add",
      edit_url: "crm/clues.index/edit",
      delete_url: "crm/clues.index/delete",
      modify_url: "crm/clues.index/modify",
      recycle_url: "crm/clues.index/recycle",
      record_url: 'crm/clues.index/record',
      discard_url: 'crm/clues.index/discard',
      turnCustomer_url: 'crm/clues.index/turnCustomer',
    };
  
    var Controller = {
      index: function () {
        ea.table.render({
          init: init,
          toolbar: ['refresh', 'add', 'delete', 'export','discard'],
          cols: [
            [
              { type: "checkbox", width: 50 },
              { field: 'id', width: 60, title: 'ID', sort: true, search:false},
              {field: "name", minWidth: 120, title: "姓名", unresize: true},
              {field: "phone", minWidth: 135, title: "手机号", unresize: true},
              {
                field: "campus_id",
                minWidth: 200,
                templet: function (d) {
                  if (d.campus == null) {
                    return "暂无";
                  } else {
                    return d.campus.name;
                  }
                },
                title: "期望校区",
                search: "select",
                selectList: _campusList,
                unresize: true,
              },
              {
                field: "course_id",
                minWidth: 200,
                templet: function (d) {
                  if (d.course == null) {
                    return "暂无";
                  } else {
                    return d.course.name;
                  }
                },
                title: "咨询课程",
                search: "select",
                selectList: _courseList,
                unresize: true,
              },
              {
                field: "remark",
                minWidth: 135,
                title: "备注",
                templet: function (d) {
                  if (d.remark == "") {
                    return "暂无";
                  } else {
                    return d.remark;
                  }
                },
                searchOp: "%*%",
                unresize: true,
              },
              {
                field: "create_user_id",  
                minWidth: 135,
                title: "录入人",
                search: "false",
                templet: function (d) {
               
                    return d.create_user.username;
                  
                },
                unresize: true,
              },
              {
                field: "create_time",
                minWidth: 135,
                title: "创建时间",
                search: "range",
                unresize: true,
              },
  
              {
                field: "update_time",
                minWidth: 135,
                title: "更新时间",
                search: "range",
                unresize: true,
              },
              {
                field: "status",
                minWidth: 135,
                title: "状态",
                selectList: {0: "待处理", 1: "回访中", 2: "已转正"},
                unresize: true,
              },
              { 
                title: '操作', 
                minWidth: 200, 
                width: 250,
                templet: ea.table.tool,
                align: "center", 
                fixed: 'right',
                operat: ['ClueRecord', 'turnCustomer','edit','delete']
              }
            ],
          ],
        });
  
        ea.listen();
      },
      add: function () {
        ea.listen();
      },
      edit: function () {
        ea.listen();
      },
      record: function () {
        ea.listen();
      },
    };
    return Controller;
  });
  